package com.jytc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class SqlServerTest {

	/**
	 * @param args
	 * @throws ClassNotFoundException 
	 * @throws IllegalAccessException 
	 * @throws InstantiationException 
	 * @throws SQLException 
	 */
	public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
		String url2 = "jdbc:jtds:sqlserver://192.168.16.100:1433/FDBRestDat";
		String driver2 = "net.sourceforge.jtds.jdbc.Driver";
		String userName = "sa";
		String password = "";
		//Class.forName(driver); 
		Class.forName(driver2).newInstance();
		Connection conn = DriverManager.getConnection(url2, userName, password);
		Statement stat = conn.createStatement();
		String sql = "select count(*) a from UserReport t";
		ResultSet rs = stat.executeQuery(sql);
		while(rs.next())
		{
			System.out.println(rs.getInt(1));
		}
	}

}
